package com.accp.jboa.action;

import com.accp.jboa.biz.Employeebiz;
import com.accp.jboa.pojo.Employee;
import com.accp.jboa.pojo.Leave;
import com.accp.jboa.vo.Leaves;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/employee")
public class EmployeeAction {

    @Autowired(required = false)
    private Employeebiz employeebiz;

    @PostMapping("/login")
    public Map<String,String> queryBynameAndpwd(@RequestBody Employee employee){
        Map<String,String> map = new HashMap<>();
        Employee employee1 = employeebiz.queryBynameAndpwd(employee);
        if (employee1!=null){
            map.put("id",employee1.getEmployeeid().toString());
            map.put("code","200");
            map.put("msg","登录成功");
            return map;
        }else {
            map.put("code","400");
            map.put("msg","登录失败");
            return map;
        }
    }

    @GetMapping("/queryByid/{id}")
    public Employee queryByid(@PathVariable Integer id){
        return employeebiz.selectByid(id);
    }

    @GetMapping("Byid/{id}")
    public Employee Byid(@PathVariable Integer id){
        return employeebiz.Byid(id);
    }

}
